Could someone post DXL code to copy and paste an entire sheet in Excel? |
Re: Excel copy paste sheet
I have some old code floating around. Unfortunately it is embedded in a bug Excel library that I cannot post entirely, but something like this should do the trick?
...
OleAutoArgs args = create()
put (args, objWorksheetTarget)
put (args, "Before")
oleMethod (objWorkSheetSource, "Copy", args )
...
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Excel copy paste sheet Mathias Mamsch - Thu Jul 07 03:15:22 EDT 2011
I have some old code floating around. Unfortunately it is embedded in a bug Excel library that I cannot post entirely, but something like this should do the trick?
...
OleAutoArgs args = create()
put (args, objWorksheetTarget)
put (args, "Before")
oleMethod (objWorkSheetSource, "Copy", args )
...
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Excel copy paste sheet SystemAdmin - Thu Jul 07 09:38:59 EDT 2011
Sorry I was misreading my old code. Here is a complete Example (start it with an open excel Sheet):
OleAutoObj objEx = oleGetAutoObject("Excel.Application")
if (null objEx) { print "Please open Excel!"; halt }
OleAutoObj objSheet = null
oleGet(objEx, "ActiveSheet", objSheet)
if (null objEx) { print "Cannot find sheet. Please open a workbook!"; halt }
OleAutoArgs args = create()
put (args, "Before", objSheet)
oleMethod(objSheet, "Copy", args)
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Excel copy paste sheet Mathias Mamsch - Fri Jul 08 06:12:59 EDT 2011
Sorry I was misreading my old code. Here is a complete Example (start it with an open excel Sheet):
OleAutoObj objEx = oleGetAutoObject("Excel.Application")
if (null objEx) { print "Please open Excel!"; halt }
OleAutoObj objSheet = null
oleGet(objEx, "ActiveSheet", objSheet)
if (null objEx) { print "Cannot find sheet. Please open a workbook!"; halt }
OleAutoArgs args = create()
put (args, "Before", objSheet)
oleMethod(objSheet, "Copy", args)
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
I got the following code to work:
OleAutoObj objEx = oleGetAutoObject("Excel.Application")
if (null objEx) { print "Please open Excel!"; halt }
OleAutoObj objSheet = null
oleGet(objEx, "ActiveSheet", objSheet)
// changed check for null objEx to objSheet
if (null objSheet) { print "Cannot find sheet. Please open a workbook!"; halt }
OleAutoArgs args = create()
put (args, "Before", objSheet)
oleMethod(objSheet, "Copy", args)
// deleting OleAutoArgs
delete args
|
Re: Excel copy paste sheet SystemAdmin - Fri Jul 08 11:10:05 EDT 2011 I got the following code to work:
OleAutoObj objEx = oleGetAutoObject("Excel.Application")
if (null objEx) { print "Please open Excel!"; halt }
OleAutoObj objSheet = null
oleGet(objEx, "ActiveSheet", objSheet)
// changed check for null objEx to objSheet
if (null objSheet) { print "Cannot find sheet. Please open a workbook!"; halt }
OleAutoArgs args = create()
put (args, "Before", objSheet)
oleMethod(objSheet, "Copy", args)
// deleting OleAutoArgs
delete args
See for example: https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14638385� https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14585977� The OLE Method failed message comes from another part of your code (judging from the error message some call to Select Range). You can find it by inserting a dxlHere() into your "Ole Method Failed" error message. Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |